#!/usr/bin/cmake
#   Copyright (c) 2010, Jonathan Baldwin
#   All rights reserved.
# 
#   Redistribution and use in source and binary forms, with or without modification,
#   are permitted provided that the following conditions are met:
# 
#   * Redistributions of source code must retain the above copyright notice, this
#     list of conditions and the following disclaimer.
#   * Redistributions in binary form must reproduce the above copyright notice, this
#     list of conditions and the following disclaimer in the documentation and/or
#     other materials provided with the distribution.
# 
#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
#   ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
#   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
#   DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
#   ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
#   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
#   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
#   ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
#   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

project(recap)
cmake_minimum_required(VERSION 2.6)

#main target
find_package(Qt4 REQUIRED)

include_directories(${CMAKE_CURRENT_BINARY_DIR} common kde nogui
x11 ${QT_INCLUDES})

file(GLOB_RECURSE recap_SOURCES . *.cpp)
file(GLOB_RECURSE recap_CSOURCES . *.c)
file(GLOB_RECURSE recap_HEADERS . *.h)
file(GLOB_RECURSE recap_UIFACES . *.ui)

add_definitions(-D__STDC_CONSTANT_MACROS)
add_definitions(-D__RECAP_USE_QT)

if(recap_HEADERS)
    qt_wrap_cpp(recap recap_SOURCES_MOC ${recap_HEADERS})
endif(recap_HEADERS)

if(recap_UIFACES)
    qt_wrap_ui (recap recap_HEADERS_UI recap_SOURCES_UI ${recap_UIFACES})
endif(recap_UIFACES)

#set(recap_PUBLIC_HEADERS ${recap_HEADERS})

#foreach(header ${recap_PUBLIC_HEADERS})
#string(REGEX REPLACE "\^.+/" "" header_local ${header} )
#set(RECAP_PUBLIC_INCLUDES "${RECAP_PUBLIC_INCLUDES}\n\#include
#\"${header_local}\"")
#endforeach(header)

#message(${RECAP_PUBLIC_INCLUDES})

#configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/recap.h.in
#${CMAKE_CURRENT_BINARY_DIR}/include/recap.h)

add_executable(recap ${recap_SOURCES} ${recap_CSOURCES} ${recap_SOURCES_MOC}
${recap_SOURCES_UI})
target_link_libraries(recap ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} X11 Xcomposite Xrender Xdamage avcodec avutil avformat swscale)

#doc target
#find_package(Doxygen)
#if(DOXYGEN_FOUND)
#  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
#${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
#  add_custom_target(doxygen ${DOXYGEN_EXECUTABLE}
#${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
#  get_target_property(DOC_TARGET doc TYPE)
#  if(NOT DOC_TARGET)
#    add_custom_target(doc)
#  endif(NOT DOC_TARGET)
#  add_dependencies(doc doxygen)
#endif(DOXYGEN_FOUND)
